/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : battleLogic
	/// </summary>
	public class BattleSkillPOD : IPOD 
    {
        public readonly static Func<BattleSkillPOD> FACTORY = () => new BattleSkillPOD();
		public static Func<BattleSkillPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public int unitId;
		/// <summary>
        /// 
        /// </summary>
		public int skillId;
		/// <summary>
        /// 
        /// </summary>
		public Vector2POD pos;
		/// <summary>
        /// 
        /// </summary>
		public Vector2POD forward;
		/// <summary>
        /// 
        /// </summary>
		public int targetId;
		/// <summary>
        /// 
        /// </summary>
		public Vector2POD targetPos;
		/// <summary>
        /// 
        /// </summary>
		public Vector2POD targetAspect;
		
		
		
		/*-- constructors --*/
		public BattleSkillPOD() {}
		public BattleSkillPOD(int unitId, int skillId, Vector2POD pos, Vector2POD forward, int targetId, Vector2POD targetPos, Vector2POD targetAspect) {
			this.unitId = unitId;
			this.skillId = skillId;
			this.pos = pos;
			this.forward = forward;
			this.targetId = targetId;
			this.targetPos = targetPos;
			this.targetAspect = targetAspect;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(unitId);
            _out.Write_int(skillId);
            _out.Write_pod(pos);
            _out.Write_pod(forward);
            _out.Write_int(targetId);
            _out.Write_pod(targetPos);
            _out.Write_pod(targetAspect);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            unitId = _in.Read_int();
            if(!_in.HasRemaining()) return;
            skillId = _in.Read_int();
            if(!_in.HasRemaining()) return;
            pos = _in.Read_pod<Vector2POD>(Vector2POD.DynamicFactory);
            if(!_in.HasRemaining()) return;
            forward = _in.Read_pod<Vector2POD>(Vector2POD.DynamicFactory);
            if(!_in.HasRemaining()) return;
            targetId = _in.Read_int();
            if(!_in.HasRemaining()) return;
            targetPos = _in.Read_pod<Vector2POD>(Vector2POD.DynamicFactory);
            if(!_in.HasRemaining()) return;
            targetAspect = _in.Read_pod<Vector2POD>(Vector2POD.DynamicFactory);
        }
		
		public BattleSkillPOD Clone() {
            BattleSkillPOD o = DynamicFactory();
            o.unitId = unitId;
            o.skillId = skillId;
            if (pos != null) {
                o.pos = pos.Clone();
            }
            if (forward != null) {
                o.forward = forward.Clone();
            }
            o.targetId = targetId;
            if (targetPos != null) {
                o.targetPos = targetPos.Clone();
            }
            if (targetAspect != null) {
                o.targetAspect = targetAspect.Clone();
            }
            return o;
        }
        
        public void Clear() {
            unitId = default;
            skillId = default;
            pos = default;
            forward = default;
            targetId = default;
            targetPos = default;
            targetAspect = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "BattleSkillPOD [";
			str += "unitId=";
			str += unitId;
			str += ", skillId=";
			str += skillId;
			str += ", pos=";
			str += pos;
			str += ", forward=";
			str += forward;
			str += ", targetId=";
			str += targetId;
			str += ", targetPos=";
			str += targetPos;
			str += ", targetAspect=";
			str += targetAspect;
			str += "]";
			return str;
		}
		
	}
}